package com.weaver.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

import java.util.List;

class ModelTest {
    private Model model;

    @BeforeEach
    void setup() {
        model = new Model();
        model.initGame();
    }

    @Test
    void testTryWordInvalidLength() {
        // 测试输入长度不为4的单词
        assertFalse(model.tryWord("HELLO"));  // 长度为5
        assertFalse(model.tryWord("HI"));     // 长度为2

        // 验证游戏状态未被更新
        assertEquals(0, model.getAttemptsCount());
        assertTrue(model.getAttempts().isEmpty());
        assertFalse(model.isGameWon());
    }

    @Test
    void testSetUserRandomWords() {
        model.setUseRandomWords(true);
        model.initGame();
        assertNotNull(model.getStartWord());
        assertNotNull(model.getTargetWord());
        assertNotEquals(model.getStartWord(), model.getTargetWord());
        assertEquals(4, model.getStartWord().length());
        assertEquals(4, model.getTargetWord().length());
    }

    @Test
    void testSetShowErrorMessage() {
        model.setShowErrorMessage(false);
        assertFalse(model.isShowErrorMessage());
    }
}